package lab03.test05;

        import java.io.*;

public class Test {
    public static void main(String[] args) {
        String path = "E:\\test.txt";

        String line = "Hello";


        BufferedReader reader = null;
        BufferedWriter writer = null;

        try {
            reader = new BufferedReader(new FileReader(path));
            writer = new BufferedWriter(new FileWriter(path));
            StringBuffer stringBuffer = new StringBuffer();

            for (int i = 0;i<line.length();i++){
                char ch = (char) (line.charAt(i)+1);
                stringBuffer.append(ch);
            }

            writer.write(String.valueOf(stringBuffer));
            writer.newLine();
            writer.close();
            System.out.println("加密后为："+stringBuffer);

            String line1 = reader.readLine();;
            StringBuffer stringBuffer1 = new StringBuffer();
            for (int i = 0;i<line1.length();i++){
                stringBuffer1.append((char)(line1.charAt(i)-1));
            }
            System.out.println("读取文件解密后为"+stringBuffer1);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
